package com.boarsoft.message.activemq;

import com.boarsoft.message.core.MessageService;

/**
 * 基于ActiveMQ客户端完成JMS消息的外发<br>
 * 应用可以直接使用ActiveMQ的API完成外发，也可以通过本类来完成<br>
 * 将AmqClient的实例，按MessageService接口注入Messenger即可。
 * 
 * @author Mac_J
 *
 */
public class AmqClientEx extends AmqClient implements MessageService {

	public com.boarsoft.message.bean.Message get(String from) throws Exception {
		AmqDestination d = destMap.get(from);
		AmqConsumerEx c = (AmqConsumerEx) d.getConsumer();
		return c.get();
	}

	@Override
	public void put(com.boarsoft.message.bean.Message msg) throws Exception {
		this.prepare();
		String target = msg.getTarget();
		AmqDestination dest = destMap.get(target);
		AmqProducerEx producer = (AmqProducerEx) dest.getProducer();
		producer.put(msg);
	}
}